package com.lingx.web.api;

import java.util.HashMap;
import java.util.Map;

public interface IApi {

	public int getApiCode();
	public String getApiName();
	public String getGroupName();
	/**
	 * 接口鉴权
	 * 40001为TOKEN失效，要重登
	 * 40002为没有操作权限
	 * @param params
	 * @return 错误代码，返回0为正常
	 */
	public int before(Map<String,Object> params) ;
	
	public Map<String,Object> api(Map<String,Object> params);
	


	
	public static Map<String,Object> getRetMap(){
		return getRetMap(1,"SUCCESS");
	}
	public static Map<String,Object> getRetMap(int code,String message){
		Map<String,Object> ret=new HashMap<String,Object>();
		ret.put("code", code);
		ret.put("message", message);
		return ret;
	}
	
	public static String getParamString(Map<String,Object> params,String key,String defaultValue) {
		if(params.containsKey(key)&&params.get(key)!=null) {
			return params.get(key).toString();
		}else {
			return defaultValue;
		}
	}
	
	public boolean isLog() ;
}
